﻿using System.Configuration;

namespace FileDistributor.Configuration
{
    public class FtpServerConnectionElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new FtpServerConnectionElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return element;
        }

        protected override bool IsElementName(string elementName)
        {
            FtpServerConnectionElement local = new FtpServerConnectionElement();
            return (!string.IsNullOrEmpty(elementName) && elementName == local.ElementName);
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMapAlternate;
            }
        }

        public FtpServerConnectionElement this[int index]
        {
            get
            {
                return (FtpServerConnectionElement)BaseGet(index);
            }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }
                BaseAdd(index, value);
            }
        }

        protected override string ElementName
        {
            get
            {
                return "ftpServerConnection";
            }
        }

    }
}
